//
//  HGIntefralVC.m
//  RedWinMall
//
//  Created by HeDianZhao on 2018/8/3.
//  Copyright © 2018年 HeDianZhao. All rights reserved.
//

#import "HGIntegralCell.h"
#import "HGIntegralModel.h"
#import "HGFansModel.h"

@interface HGIntegralCell ()

@property (strong, nonatomic) NSMutableArray<UILabel *> *labels;

@end

@implementation HGIntegralCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initSubViews];
    }
    return self;
}

- (void)setModel:(HGIntegralModel *)model {
    _model = model;
    NSArray *datas = @[model.createTimeText, model.amountFrom, model.money];
    [_labels enumerateObjectsUsingBlock:^(UILabel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        obj.text = datas[idx];
    }];
}

- (void)setFansModel:(HGFansModel *)fansModel {
    _fansModel = fansModel;
    NSArray *datas = @[fansModel.date, fansModel.grayText, fansModel.redText];
    [_labels enumerateObjectsUsingBlock:^(UILabel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        obj.text = datas[idx];
    }];
}

- (void)initSubViews {
    
    UIView *bgView = [[UIView alloc] init];
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(15);
        make.top.right.bottom.equalTo(self.contentView);
    }];
    for (int i = 0; i < 3; i++) {
        UILabel *label = [[UILabel alloc] init];
        label.text = @"----";
        label.textColor = kColorText;
        label.font = [UIFont systemFontOfSize:12];
        label.textAlignment = i < 2 ? NSTextAlignmentLeft : NSTextAlignmentCenter;
        [bgView addSubview:label];
        [self.labels addObject:label];
    }
    
    [self.labels mas_distributeViewsAlongAxis:(MASAxisTypeHorizontal) withFixedSpacing:0 leadSpacing:0 tailSpacing:0];
    [self.labels mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(bgView);
    }];
}

- (NSMutableArray<UILabel *> *)labels {
    if (!_labels) {
        _labels = [@[] mutableCopy];
    }
    return _labels;
}

@end
